﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Antlr.Runtime;
using Antlr.Runtime.Tree;

namespace i4pro_gruppe_d.DomainSpecificLanguage
{
    public class Compiler
    {
        public List<String> errorList = new List<string>();

        public CommonTree Compile(string _input)
        {
            var reader = new ANTLRStringStream(_input);
            //var reader = new ANTLRFileStream("test.txt");
            DSLLexer lex = new DSLLexer(reader);
            CommonTokenStream tokens = new CommonTokenStream(lex);
            DSLParser parser = new DSLParser(tokens);
            

            DSLParser.program_return result = new DSLParser.program_return();
            result = parser.program();
            errorList = parser.GetErrors();
            var tree = result.Tree as CommonTree;
            
            return tree;
        }

        public List<String> GetErrorList()
        {
            return errorList;
        }
   }
}
